

function crush = nearestD(Car)
% 距离检测 返回最小距离 *
% 用于检测是否碰撞
% get the current nearest dispart between car and the edge
Edge = [
2.998806	0.220528 30.323206	15.844528;
30.323206	15.844528 23.792806	29.414528;
23.792806	29.414528 -4.748594	12.996528;
-4.748594	12.996528 2.998806	0.220528;% A


%11.149906	18.121528 -3.120794	9.912528;%B

%12.777706	15.037528 -1.492994	6.828528;%C

1.380606	2.756528 15.301006	10.696528;
15.301006	10.696528 14.405506	11.953528;
14.405506	11.953528 0.134806	3.744528;
0.134806	3.744528 1.380606	2.756528;%D


];

crush=10;

for i=1:length(Edge)
    r = disMin([Edge(i,1),Edge(i,2)],[Edge(i,3),Edge(i,4)],Car);
    for j = 1:length(r)
          if r(j)<crush
       crush = r(j);
    end
    end
  
end

